---
layout: "default"
title: "Operator: &"
description: "Swift documentation for the '&' operator."
root: "/v4.2"
---

<code class="language-swift"> operator &amp; {
    associativity left
    precedence 
}</code>

<h3>Declarations</h3>

<div class="declaration" id="func-amp_-int-rhs_-int">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-amp_-int-rhs_-int">func &amp;(<wbr>_:<wbr> Int, rhs: Int)</a>
        
<div class="comment collapse" id="comment-func-amp_-int-rhs_-int"><div class="p">
    <p>Returns the result of performing a bitwise AND operation on the two given
values.</p>

<p>A bitwise AND operation results in a value that has each bit set to <code>1</code>
where <em>both</em> of its arguments have that bit set to <code>1</code>. For example:</p>

<pre><code class="language-swift">let x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
let z = x &amp; y             // 0b00000100
// z == 4</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> An integer value.
  <strong>rhs:</strong> Another integer value.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;(lhs: Int, rhs: Int) -&gt; Int</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/Int/"><code>Int</code></a>,    <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration" id="func-amp_-int8-rhs_-int8">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-amp_-int8-rhs_-int8">func &amp;(<wbr>_:<wbr> Int8, rhs: Int8)</a>
        
<div class="comment collapse" id="comment-func-amp_-int8-rhs_-int8"><div class="p">
    <p>Returns the result of performing a bitwise AND operation on the two given
values.</p>

<p>A bitwise AND operation results in a value that has each bit set to <code>1</code>
where <em>both</em> of its arguments have that bit set to <code>1</code>. For example:</p>

<pre><code class="language-swift">let x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
let z = x &amp; y             // 0b00000100
// z == 4</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> An integer value.
  <strong>rhs:</strong> Another integer value.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;(lhs: Int8, rhs: Int8) -&gt; Int8</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/Int8/"><code>Int8</code></a>,    <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration" id="func-amp_-int16-rhs_-int16">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-amp_-int16-rhs_-int16">func &amp;(<wbr>_:<wbr> Int16, rhs: Int16)</a>
        
<div class="comment collapse" id="comment-func-amp_-int16-rhs_-int16"><div class="p">
    <p>Returns the result of performing a bitwise AND operation on the two given
values.</p>

<p>A bitwise AND operation results in a value that has each bit set to <code>1</code>
where <em>both</em> of its arguments have that bit set to <code>1</code>. For example:</p>

<pre><code class="language-swift">let x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
let z = x &amp; y             // 0b00000100
// z == 4</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> An integer value.
  <strong>rhs:</strong> Another integer value.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;(lhs: Int16, rhs: Int16) -&gt; Int16</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/Int16/"><code>Int16</code></a>,    <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration" id="func-amp_-int32-rhs_-int32">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-amp_-int32-rhs_-int32">func &amp;(<wbr>_:<wbr> Int32, rhs: Int32)</a>
        
<div class="comment collapse" id="comment-func-amp_-int32-rhs_-int32"><div class="p">
    <p>Returns the result of performing a bitwise AND operation on the two given
values.</p>

<p>A bitwise AND operation results in a value that has each bit set to <code>1</code>
where <em>both</em> of its arguments have that bit set to <code>1</code>. For example:</p>

<pre><code class="language-swift">let x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
let z = x &amp; y             // 0b00000100
// z == 4</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> An integer value.
  <strong>rhs:</strong> Another integer value.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;(lhs: Int32, rhs: Int32) -&gt; Int32</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/Int32/"><code>Int32</code></a>,    <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration" id="func-amp_-int64-rhs_-int64">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-amp_-int64-rhs_-int64">func &amp;(<wbr>_:<wbr> Int64, rhs: Int64)</a>
        
<div class="comment collapse" id="comment-func-amp_-int64-rhs_-int64"><div class="p">
    <p>Returns the result of performing a bitwise AND operation on the two given
values.</p>

<p>A bitwise AND operation results in a value that has each bit set to <code>1</code>
where <em>both</em> of its arguments have that bit set to <code>1</code>. For example:</p>

<pre><code class="language-swift">let x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
let z = x &amp; y             // 0b00000100
// z == 4</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> An integer value.
  <strong>rhs:</strong> Another integer value.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;(lhs: Int64, rhs: Int64) -&gt; Int64</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/Int64/"><code>Int64</code></a>,    <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration" id="func-amp_-uint-rhs_-uint">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-amp_-uint-rhs_-uint">func &amp;(<wbr>_:<wbr> UInt, rhs: UInt)</a>
        
<div class="comment collapse" id="comment-func-amp_-uint-rhs_-uint"><div class="p">
    <p>Returns the result of performing a bitwise AND operation on the two given
values.</p>

<p>A bitwise AND operation results in a value that has each bit set to <code>1</code>
where <em>both</em> of its arguments have that bit set to <code>1</code>. For example:</p>

<pre><code class="language-swift">let x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
let z = x &amp; y             // 0b00000100
// z == 4</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> An integer value.
  <strong>rhs:</strong> Another integer value.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;(lhs: UInt, rhs: UInt) -&gt; UInt</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/UInt/"><code>UInt</code></a>,    <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration" id="func-amp_-uint8-rhs_-uint8">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-amp_-uint8-rhs_-uint8">func &amp;(<wbr>_:<wbr> UInt8, rhs: UInt8)</a>
        
<div class="comment collapse" id="comment-func-amp_-uint8-rhs_-uint8"><div class="p">
    <p>Returns the result of performing a bitwise AND operation on the two given
values.</p>

<p>A bitwise AND operation results in a value that has each bit set to <code>1</code>
where <em>both</em> of its arguments have that bit set to <code>1</code>. For example:</p>

<pre><code class="language-swift">let x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
let z = x &amp; y             // 0b00000100
// z == 4</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> An integer value.
  <strong>rhs:</strong> Another integer value.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;(lhs: UInt8, rhs: UInt8) -&gt; UInt8</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/UInt8/"><code>UInt8</code></a>,    <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration" id="func-amp_-uint16-rhs_-uint16">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-amp_-uint16-rhs_-uint16">func &amp;(<wbr>_:<wbr> UInt16, rhs: UInt16)</a>
        
<div class="comment collapse" id="comment-func-amp_-uint16-rhs_-uint16"><div class="p">
    <p>Returns the result of performing a bitwise AND operation on the two given
values.</p>

<p>A bitwise AND operation results in a value that has each bit set to <code>1</code>
where <em>both</em> of its arguments have that bit set to <code>1</code>. For example:</p>

<pre><code class="language-swift">let x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
let z = x &amp; y             // 0b00000100
// z == 4</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> An integer value.
  <strong>rhs:</strong> Another integer value.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;(lhs: UInt16, rhs: UInt16) -&gt; UInt16</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/UInt16/"><code>UInt16</code></a>,    <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration" id="func-amp_-uint32-rhs_-uint32">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-amp_-uint32-rhs_-uint32">func &amp;(<wbr>_:<wbr> UInt32, rhs: UInt32)</a>
        
<div class="comment collapse" id="comment-func-amp_-uint32-rhs_-uint32"><div class="p">
    <p>Returns the result of performing a bitwise AND operation on the two given
values.</p>

<p>A bitwise AND operation results in a value that has each bit set to <code>1</code>
where <em>both</em> of its arguments have that bit set to <code>1</code>. For example:</p>

<pre><code class="language-swift">let x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
let z = x &amp; y             // 0b00000100
// z == 4</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> An integer value.
  <strong>rhs:</strong> Another integer value.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;(lhs: UInt32, rhs: UInt32) -&gt; UInt32</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/UInt32/"><code>UInt32</code></a>,    <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
<div class="declaration" id="func-amp_-uint64-rhs_-uint64">
<a class="toggle-link" data-toggle="collapse" href="#comment-func-amp_-uint64-rhs_-uint64">func &amp;(<wbr>_:<wbr> UInt64, rhs: UInt64)</a>
        
<div class="comment collapse" id="comment-func-amp_-uint64-rhs_-uint64"><div class="p">
    <p>Returns the result of performing a bitwise AND operation on the two given
values.</p>

<p>A bitwise AND operation results in a value that has each bit set to <code>1</code>
where <em>both</em> of its arguments have that bit set to <code>1</code>. For example:</p>

<pre><code class="language-swift">let x: UInt8 = 5          // 0b00000101
let y: UInt8 = 14         // 0b00001110
let z = x &amp; y             // 0b00000100
// z == 4</code></pre>

<p><strong>Parameters:</strong>
  <strong>lhs:</strong> An integer value.
  <strong>rhs:</strong> Another integer value.</p>

    <h4>Declaration</h4>    
    <code class="language-swift">func &amp;(lhs: UInt64, rhs: UInt64) -&gt; UInt64</code>
    
        <h4>Declared In</h4>
        <a href="../../protocol/UInt64/"><code>UInt64</code></a>,    <a href="../../protocol/FixedWidthInteger/"><code>FixedWidthInteger</code></a>    
</div></div>
</div>
